package tests;

import static org.junit.Assert.assertEquals;

import java.io.File;
import java.io.IOException;
import java.util.Date;

import org.junit.Before;
import org.junit.Test;

import papers.Manuscript;
import users.Author;
import conference.WritetoFile;

/**
 * 
 * @author Taylor Zielske
 * @version December 4, 2011
 *
 */
public class TestWritetoFile {
	private Author my_author;
	private Manuscript my_manu;
	private File my_file = new File("ThisisusedforWritetoFileTest.txt");
	private String my_content = "Testing 123 \n \n Testing 123";
	/**
	 * Initializes the Author and Manuscript
	 */
	@Before
	public void setUp() {
		my_author = new Author("Taylor");
		my_manu = new Manuscript(my_author, new Date(), "Paper1",
				new File("ThisisusedforWritetoFileTest.txt"));
	}
	/**
	 * Tests reading from file
	 * @throws IOException  
	 */
	@Test
	public void TestGetFileContent() throws IOException{
		String manutext = WritetoFile.getFileContent(my_manu.getPaper());
		assertEquals("This should be equal", manutext, my_content);
		

	}
	/**
	 * Tests writing to file.
	 * @throws IOException  
	 */
	@Test
	public void TesttoFileContent() throws IOException{
		WritetoFile.toFileContent(my_content, my_file);
		String manutext = WritetoFile.getFileContent(my_manu.getPaper());
		assertEquals("This should be equal", manutext, my_content);
	}
}
